# MenuItem - Simple Menuitem
# Copyright (C) 2007 Lauri Taimila
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

__licence__ = "GPLv2"
__copyright__ = "2007, Lauri Taimila"
__author__ = "Lauri Taimila <lauri@taimila.com>"

import clutter

class MenuItem(clutter.Group):
    """
    Simple menuitem widget. 
    
    This is a base class for all menuitem types. MenuItems are supposed to be
    used in Menus which inherit GridMenu class.
    """
    
    def __init__(self, width, height):
        """
        Initialize menuitem.
        @param width: Width of the menuitem
        @param height: Height of the menuitem
        """
        clutter.Group.__init__(self)
        self.active = False
        self.data = None
        
        rect = clutter.Rectangle()
        rect.set_size(width, height)
        rect.set_color(clutter.Color(0,0,0,0))
        rect.show()
        self.add(rect)
        
    def set_active(self, boolean):
        """
        Set menuitem active / inactive.
        @param boolean: use True to set active and False to set inactive
        """
        self.active = boolean
                    
    def is_active(self):
        """
        Get widget status.
        @return True if widget is active, otherwise False
        """
        return self.active

    def set_userdata(self, data):
        """
        Set user data for this menuitem.
        @param id: ID string
        """
        self.data = data
        
    def get_userdata(self):
        """
        Get user data
        @return: string
        """
        return self.data